using Autodesk.Revit.DB;
using System.Windows;
using System.Windows.Controls;
using CodRevit.ViewModels;

namespace CodRevit.Views
{
    public partial class DeleteFilterView : Window
    {
        public DeleteFilterView()
        {
            InitializeComponent();
        }

        private void CheckBox_Changed(object sender, RoutedEventArgs e)
        {
            if (DataContext is DeleteFilterViewModel vm)
            {
                var checkBox = sender as CheckBox;
                var filter = checkBox?.DataContext as ParameterFilterElement;

                if (filter != null)
                {
                    if (checkBox.IsChecked == true)
                    {
                        if (!vm.SelectedFilters.Contains(filter))
                        {
                            vm.SelectedFilters.Add(filter);
                        }
                    }
                    else
                    {
                        vm.SelectedFilters.Remove(filter);
                    }
                }
            }
        }
    }
}